<?php
namespace App\Repository;

use App\Model\UserTransfer;

class UserTransferRepository extends \HyperfStore\Repository
{
    // 放入模型
    public function build()
    {
        return new UserTransfer;
    }

    // 创建
    public function create(UserRepository $user, UserRepository $to, $data)
    {
        $this->model->user()->associate($user->model());
        $this->model->toUser()->associate($to->model());
        
        // 实际到帐
        $data['money_now'] = $data['money'] - $data['tax'];

        return $this->save($data);
    }
}